//
// Created by 11510 on 2024/6/18.
//
#include <iostream>

using namespace std;

class A {
public:
    virtual void func(int val = 1) {
        cout << "A->" << val << endl;
    }

    virtual void test() {
        func();
    }

private:
    long _a;
};

class B : public A {
public:
    /**
     * 覆盖了父类的内容；函数名、返回值、默认值没有覆盖
     * @param val
     */
    virtual void func(int val = 10) {
        cout << "B->" << val << endl;
    }

private:
    long _b;
};

class C : public B {
    virtual void func(int val = 10) {
        cout << "C->" << val << endl;
    }

};

int main(void) {
    B b;
    A *p1 = (A *) &b;
    B *p2 = &b;
    p1->func();
    p2->func();
    /**
     * B->1
     * B->10
     *
     */

    return 0;
}